/**
 * @param {number[]} prices
 * @return {number}
 */
 var maxProfit = function(prices) {
  let res = 0
  for(let i=0;i<prices.length;i++){
    res = Math.max(res,Math.max(prices[i],...prices.slice(i+1))-prices[i])
  }
  return res
};